package com.pms.house;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.espirit.eap.ICheckModelDuplicateInfo;
import com.espirit.eap.PinyinAware;
import com.espirit.eap.annotation.DomainModel;
import com.pms.charge.ARItem;
import com.pms.manager.HouseDebitChargeItemStandard;

@Entity
@DomainModel
public class House implements Serializable , ICheckModelDuplicateInfo, PinyinAware{

	private static final long serialVersionUID = -7754683765864459007L;
	
	private Integer id;
	
	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	private String code;
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	private BigDecimal buildArea;
	private BigDecimal innerArea;
	private BigDecimal publicArea;
	private Integer status;
	private String remark;
	private Building building;
	private Integer houseType;
	private Integer houseStatus;

	public BigDecimal getBuildArea() {
		return buildArea;
	}

	public void setBuildArea(BigDecimal buildArea) {
		this.buildArea = buildArea;
	}

	public BigDecimal getInnerArea() {
		return innerArea;
	}

	public void setInnerArea(BigDecimal innerArea) {
		this.innerArea = innerArea;
	}

	public BigDecimal getPublicArea() {
		return publicArea;
	}

	public void setPublicArea(BigDecimal publicArea) {
		this.publicArea = publicArea;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@ManyToOne(targetEntity=Building.class,fetch=FetchType.LAZY)
	public Building getBuilding() {
		return building;
	}

	public void setBuilding(Building building) {
		this.building = building;
	}
	
	
	@OneToMany(targetEntity = ARItem.class ,orphanRemoval = true, fetch=FetchType.LAZY,  cascade = CascadeType.ALL,mappedBy = "house")
	public List<ARItem> getArItems() {
		return arItems;
	}

	public void setArItems(List<ARItem> arItems) {
		this.arItems = arItems;
	}

	@OneToMany(targetEntity = HouseDebitChargeItemStandard.class ,orphanRemoval = true, fetch=FetchType.LAZY,  cascade = CascadeType.ALL,mappedBy = "house")
	public List<HouseDebitChargeItemStandard> getHouseChargeItemStandards() {
		return houseChargeItemStandards;
	}

	public void setHouseChargeItemStandards(List<HouseDebitChargeItemStandard> chargeItemStandards) {
		this.houseChargeItemStandards = chargeItemStandards;
	}

	public Integer getHouseType() {
		return houseType;
	}

	public void setHouseType(Integer houseType) {
		this.houseType = houseType;
	}

	public Integer getHouseStatus() {
		return houseStatus;
	}

	public void setHouseStatus(Integer houseStatus) {
		this.houseStatus = houseStatus;
	}

	private List<ARItem> arItems; 
	private List<HouseDebitChargeItemStandard> houseChargeItemStandards;

	private final static String[] gatherProperties = new String[]{"code"};
	@Override
	public String[] gatherProperties() {
		return gatherProperties;
	}


	private String pinyin;

	public String getPinyin() {
		return pinyin;
	}

	public String source() {
		return code;
	}

	@Override
	public void setPinyin(String pinyin) {
		this.pinyin = pinyin;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		House other = (House) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	
	
}
